/**
 * 
 */
package org.manggis.io;

import java.io.IOException;
import java.io.InputStream;

import org.manggis.util.ClassUtil;
import org.manggis.util.StringUtil;

/**
 * @author ppacka
 *
 */
public class ClassPathResource extends Resource {

	public ClassPathResource(Class clazz) {
		super(StringUtil.getClassAsResourcePath(clazz), CLASS_PREFIX);
	}

	protected InputStream getResourceStream() throws IOException {
		InputStream stream = ClassUtil.getClassLoader().getResourceAsStream(resourcePath);
		if (stream == null) {
			throw new IOException("'" + resourcePath + "' is not found.");
		}
		return stream;
	}
	
}
